package com.imooc.distributedemo.resume.distribute;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;

import java.math.BigDecimal;
import java.nio.charset.Charset;

public class BloomFilterDemo {
    public static void main(String[] args) {

        BigDecimal b1 = new BigDecimal(1);
        BigDecimal b2 = new BigDecimal(1.0);
        System.out.println(b1.equals(b2));
        // 创建bloomfilter
        // 预计插入100个元素，误判率威0.001
        BloomFilter bloomFilter = BloomFilter.create(Funnels.stringFunnel(Charset.defaultCharset()),100,0.01);
//        insert elements

        bloomFilter.put("hi");
        bloomFilter.put("dddd");
        bloomFilter.put("123");
        System.out.println(bloomFilter.mightContain("dddd"));
        System.out.println(bloomFilter.mightContain("yes"));

    }
}
